package com.sjy.project.ent.yearSta.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.sjy.framework.aspectj.lang.annotation.Log;
import com.sjy.framework.aspectj.lang.enums.BusinessType;
import com.sjy.project.ent.yearSta.domain.EntRentInLand;
import com.sjy.project.ent.yearSta.service.IEntRentInLandService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import com.sjy.framework.web.controller.BaseController;
import com.sjy.framework.web.domain.AjaxResult;
import com.sjy.common.utils.poi.ExcelUtil;
import com.sjy.framework.web.page.TableDataInfo;

/**
 * 承租土地Controller
 * 
 * @author ljb
 * @date 2022-06-07
 */
@Controller
@Api(value = "亩均工业企业绩效综合考评接口相关", tags = {"亩均接口Test"})
@RequestMapping("/ent/rentInLand")
public class EntRentInLandController extends BaseController
{
    private String prefix = "ent/yearSta";

    @Autowired
    private IEntRentInLandService entRentInLandService;

    @RequiresPermissions("ent:yearSta:view")
    @GetMapping()
    public String yearSta()
    {
        return prefix + "/yearSta";
    }

    /**
     * 查询承租土地列表
     */
    @RequiresPermissions("ent:yearSta:list")
    @ApiOperation(value = "401、承租土地信息", position = 401, notes = "")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(EntRentInLand entRentInLand)
    {
        startPage();
        List<EntRentInLand> list = entRentInLandService.selectEntRentInLandList(entRentInLand);
        return getDataTable(list);
    }

    /**
     * 导出承租土地列表
     */
    @RequiresPermissions("ent:yearSta:export")
    @Log(title = "承租土地", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(EntRentInLand entRentInLand)
    {
        List<EntRentInLand> list = entRentInLandService.selectEntRentInLandList(entRentInLand);
        ExcelUtil<EntRentInLand> util = new ExcelUtil<EntRentInLand>(EntRentInLand.class);
        return util.exportExcel(list, "承租土地数据");
    }

    /**
     * 新增承租土地
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存承租土地
     */
    @RequiresPermissions("ent:yearSta:add")
    @Log(title = "承租土地", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(EntRentInLand entRentInLand)
    {
        return toAjax(entRentInLandService.insertEntRentInLand(entRentInLand));
    }

    /**
     * 修改承租土地
     */
    @RequiresPermissions("ent:yearSta:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        EntRentInLand entRentInLand = entRentInLandService.selectEntRentInLandById(id);
        mmap.put("entRentInLand", entRentInLand);
        return prefix + "/edit";
    }

    /**
     * 修改保存承租土地
     */
    @RequiresPermissions("ent:yearSta:edit")
    @Log(title = "承租土地", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(EntRentInLand entRentInLand)
    {
        return toAjax(entRentInLandService.updateEntRentInLand(entRentInLand));
    }

    /**
     * 删除承租土地
     */
    @RequiresPermissions("ent:yearSta:remove")
    @Log(title = "承租土地", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(entRentInLandService.deleteEntRentInLandByIds(ids));
    }
}
